<?php

/**
 * Description of Products
 *
 * @author Kopi
 */
class Types extends ModelAbstract{

    
    protected $fields = array(
        'id_types'	=> 'id',
        'name'		=> 'name',
    );
    
    private $id;
    private $name;

    
    
    public function getId() {
	return $this->id;
    }

    public function setId($id) {
	$this->id = $id;
    }

    public function getName() {
	return $this->name;
    }

    public function setName($name) {
	$this->name = $name;
    }


    public function getFields() {
	return $this->fields;
    }
    
    protected function iteratechildren($object,$xml){
	if($object)
         foreach ($object as $name => $value) {
	     if($name!='xml' && $name!='fields')
	     {
		 if (is_string($value) || is_numeric($value)) {
		     $xml->$name=$value;
		 } 
		 else {
		     $xml->$name=null;
		     $this->iteratechildren($value,$xml->$name);
		 }
	     }
         }
    }   
     
    public function getXmlFields($data = 'types')
    {
	$this->xml = new SimpleXMLElement("<$data id=\"" . $this->getId() . "\"></$data>");
	$this->iteratechildren($this,$this->xml);
	return str_replace('<?xml version="1.0"?>', '', $this->xml->asXML());
	
    }
    
    public function getValue($field)
    {
	$name = 'get' . $field;
	return $this->$name();
    }
    
        
    public function getClassName()
    {
	return __CLASS__;
    }
}

?>
